#include <iostream>
using namespace std;
#include "../include/tester.h"
#include "../include/base_util.h"


// 嵌套调用
int nested_call_one(){
    cout<<"nested_call_one"<<endl;
    return 1;
}
int nested_call_two(){
    cout<<"nested_call_two"<<endl;
    target_sys_call("nested_call_two");
    nested_call_one();
    return 1;
}
int nested_call_three(){
    cout<<"nested_call_three"<<endl;
    nested_call_two();
    return 1;
}
int nested_call_four(){
    cout<<"nested_call_four"<<endl;
    nested_call_three();
    return 1;

}
int nested_call_five(){
    cout<<"nested_call_five"<<endl;
    nested_call_four();
    return 1;
}
int nested_call_six(){
    cout<<"nested_call_six"<<endl;
    nested_call_five();
    return 1;
}
int test_nested_call_main(){
    nested_call_six();
    return 1;
}

// 函数指针调用

void test_point_call(){
    int (*p_def)(int);
    p_def = inner_def_one;
    int a = p_def(1);
    target_sys_call(NULL,a);
    a = p_def(10);
    target_sys_call(NULL,a);
    p_def = inner_def_two;
    a = p_def(10);
    target_sys_call(NULL,a);
}


// 展示c++ 中返回指针，返回引用

int* return_point(int* p_a){
    if (p_a == NULL){
        return NULL;
    }
    *p_a += 1;
    return p_a;
}
int& return_index(){
    static int globle_var1 = 1;
    return globle_var1;
}
int test_return_type(){
    int a = 0;
    int* p_a = return_point(&a);
    int b = return_index();
    cout << a << endl;
    cout << b << endl;
    target_sys_call(NULL,a);
    target_sys_call(NULL,b);

    return 0;
}

// 多次调用
int add_one(int in){
    return in + 1;
}

int multiple_call(){
    int a = 1;
    int b = 1;
    int result_1 = add_one(a);
    int result_2 = add_one(result_1);
    int result_3 = add_one(b);
    int result_4 = add_one(result_3);
    cout <<"result_1: " << result_1 <<endl;
    cout <<"result_2: " << result_2 <<endl;
    cout <<"result_3: " << result_3 <<endl;
    cout <<"result_4: " << result_4 <<endl;
    target_sys_call(NULL,result_1);
    target_sys_call(NULL,result_2);
    target_sys_call(NULL,result_3);
    target_sys_call(NULL,result_4);

    return 1;
}